/* l.rexx */
parse source OS Env ThisFile
main:
    call init
    call BaseRoutine
    exit

init:
    DataFile='l.dat'
    return

BaseRoutine:
    do forever
        say
        say '===== Personal Log ====='
        say '*=End ?=Search'
        say 'Abrev 1st word: ci=CallIn co=CallOut ei=EmailIn eo=EmailOut mo=Money bo=Book ln=Link'
        say 'Input:'
        parse pull InputLine
        select 
            when word(InputLine, 1)='*' then exit 
            when word(InputLine, 1)='' then nop
            when word(InputLine, 1)='?' then do
                SearchString = word(InputLine, 2)
                if OS='UNIX' then do
                    "grep -i '"SearchString"' "DataFile
                    end 
                if OS='WIN32' then do
                    'type 'DataFile' | find /i "'SearchString'"'
                    end 
                say
                end
            when word(InputLine, 1)='ci' then do
                InputLine=delword(InputLine, 1, 1)
                InputLine='CALLIN '||InputLine
                call WriteRoutine
                end
            when word(InputLine, 1)='co' then do
                InputLine=delword(InputLine, 1, 1)
                InputLine='CALLOUT '||InputLine
                call WriteRoutine
                end
            when word(InputLine, 1)='ei' then do
                InputLine=delword(InputLine, 1, 1)
                InputLine='EMAILIN '||InputLine
                call WriteRoutine
                end
            when word(InputLine, 1)='eo' then do
                InputLine=delword(InputLine, 1, 1)
                InputLine='EMAILOUT '||InputLine
                call WriteRoutine
                end
            when word(InputLine, 1)='mo' then do
                InputLine=delword(InputLine, 1, 1)
                InputLine='MONEY '||InputLine
                call WriteRoutine
                end
            when word(InputLine, 1)='bo' then do
                InputLine=delword(InputLine, 1, 1)
                InputLine='BOOK '||InputLine
                call WriteRoutine
                end
            when word(InputLine, 1)='ln' then do
                InputLine=delword(InputLine, 1, 1)
                InputLine='LINK '||InputLine
                call WriteRoutine
                end
            otherwise do
                InputLine='INFO '||InputLine
                call WriteRoutine
                end
            end /* select */
        end /* do forever */
    return

WriteRoutine:
    NowDate=date('S')
    NowDate=substr(NowDate, 1, 4)||'-'||substr(NowDate, 5, 2)||'-'||substr(NowDate, 7, 2)
    NowTime=time()
    OutputLine=NowDate||' '||NowTime||' '||InputLine
    'echo 'OutputLine' >> 'DataFile
    return
